package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Psycho
 * @create 2022-04-26-21:02
 */
@RestController
public class ArticleFeignClientImpl implements IArticleClient {

    @Autowired
    private ApArticleService apArticleService;

    @Override
    @PostMapping("/api/v1/article/save")
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {
        return apArticleService.saveArticle(dto);
    }

    @Override
    @PostMapping("/api/v1/article/get")
    public ApArticle getOneArticle(@RequestParam("id")Long id) {
        return apArticleService.getById(id);
    }

    @Override
    @PostMapping("/api/v1/article/insert")
    public void insertOne(@RequestBody ApArticle article) {
        apArticleService.updateById(article);
    }


}
